package com.book.service.impl;

import com.book.entity.Account;
import com.book.mapper.AccountMapper;
import com.book.service.AccountInfoService;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;

/**
 * @program:
 * @ClassName:
 * @description:
 * @author: zgc
 * @date:
 * @Version 1.0
 **/
@Service
public class AccountInfoServiceImpl implements AccountInfoService {
    @Resource
    private AccountMapper accountMapper;

    @Override
    //@Cacheable(value="account", key="#root.methodName")
    public Account validateAccount(Account account) {
        Example example = new Example(Account.class);
        Example.Criteria c = example.createCriteria();
        c.andEqualTo("userName", account.getUserName());
        c.andEqualTo("password", account.getPassword());
        Account result = accountMapper.selectOneByExample(example);
        return result;
    }
   // @CachePut(value = "account", key="#root.args[0].id")
    @Override
    public int updateUserInfoById(Account account) {
        int i = accountMapper.updateByPrimaryKeySelective(account);
        return i;
    }
}
